import router from "./router"
import store from "./store"
import lockr from "lockr"
const whiteRoute = ["/login", "/g6", "/register", "/404"]
router.beforeEach(async (to, from, next) => {
  if (whiteRoute.includes(to.path)) {
    next()
  } else {
    if (lockr.get("token")) {
      store.dispatch("getUserInfo")
      next()
    } else {
      next({ path: "/login" })
    }
  }
})
